﻿using InnoWeb.CEND.BL.Infrastructure;
using InnoWeb.CEND.Core.Model.Expert;
using InnoWeb.CEND.Data;
using InnoWeb.CEND.Data.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InnoWeb.CEND.BL.Service
{
    public class ExpertService: IService<ExpertInfo>
    {
        private readonly GenericRepository<ExpertInfo> _expertRepository;
        private readonly IUnitOfWork _unitOfWork;

        public ExpertService(IUnitOfWork unitOfWork, GenericRepository<ExpertInfo> expertRepository)
        {
            this._expertRepository = expertRepository;
            this._unitOfWork = unitOfWork;
        }

        //public async Task<IQueryable<ExpertInfo>> GetAllElements()
        //{
        //    IQueryable<ExpertInfo> returnList = await _expertRepository.GetAll();
        //}

        public IQueryable<ExpertInfo> GetAllElements()
        {
            return _expertRepository.GetAll();
        }

        public ExpertInfo GetElementById(int id)
        {
            return _expertRepository.GetById(id);
        }

        public void CreateElement(ExpertInfo entity)
        {
            _expertRepository.Insert(entity);
        }

        public void UpdateElement(ExpertInfo entity)
        {
            _expertRepository.Update(entity);
        }

        public void DeleteElement(int id)
        {
            _expertRepository.Delete(id);
        }

        public void SaveChanges()
        {
            _unitOfWork.SaveChanges();
        }
    }
}
